/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class OfferAttributes
    {
    
        private String conditionField;

        private String subConditionField;

        private String conditionNoteField;

        private Boolean? willShipExpeditedField;

        private Boolean? willShipInternationalField;


        /// <summary>
        /// Gets and sets the Condition property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Condition")]
        public String Condition
        {
            get { return this.conditionField ; }
            set { this.conditionField= value; }
        }



        /// <summary>
        /// Sets the Condition property
        /// </summary>
        /// <param name="condition">Condition property</param>
        /// <returns>this instance</returns>
        public OfferAttributes WithCondition(String condition)
        {
            this.conditionField = condition;
            return this;
        }



        /// <summary>
        /// Checks if Condition property is set
        /// </summary>
        /// <returns>true if Condition property is set</returns>
        public Boolean IsSetCondition()
        {
            return  this.conditionField != null;

        }


        /// <summary>
        /// Gets and sets the SubCondition property.
        /// </summary>
        [XmlElementAttribute(ElementName = "SubCondition")]
        public String SubCondition
        {
            get { return this.subConditionField ; }
            set { this.subConditionField= value; }
        }



        /// <summary>
        /// Sets the SubCondition property
        /// </summary>
        /// <param name="subCondition">SubCondition property</param>
        /// <returns>this instance</returns>
        public OfferAttributes WithSubCondition(String subCondition)
        {
            this.subConditionField = subCondition;
            return this;
        }



        /// <summary>
        /// Checks if SubCondition property is set
        /// </summary>
        /// <returns>true if SubCondition property is set</returns>
        public Boolean IsSetSubCondition()
        {
            return  this.subConditionField != null;

        }


        /// <summary>
        /// Gets and sets the ConditionNote property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ConditionNote")]
        public String ConditionNote
        {
            get { return this.conditionNoteField ; }
            set { this.conditionNoteField= value; }
        }



        /// <summary>
        /// Sets the ConditionNote property
        /// </summary>
        /// <param name="conditionNote">ConditionNote property</param>
        /// <returns>this instance</returns>
        public OfferAttributes WithConditionNote(String conditionNote)
        {
            this.conditionNoteField = conditionNote;
            return this;
        }



        /// <summary>
        /// Checks if ConditionNote property is set
        /// </summary>
        /// <returns>true if ConditionNote property is set</returns>
        public Boolean IsSetConditionNote()
        {
            return  this.conditionNoteField != null;

        }


        /// <summary>
        /// Gets and sets the WillShipExpedited property.
        /// </summary>
        [XmlElementAttribute(ElementName = "WillShipExpedited")]
        public Boolean WillShipExpedited
        {
            get { return this.willShipExpeditedField.GetValueOrDefault() ; }
            set { this.willShipExpeditedField= value; }
        }



        /// <summary>
        /// Sets the WillShipExpedited property
        /// </summary>
        /// <param name="willShipExpedited">WillShipExpedited property</param>
        /// <returns>this instance</returns>
        public OfferAttributes WithWillShipExpedited(Boolean willShipExpedited)
        {
            this.willShipExpeditedField = willShipExpedited;
            return this;
        }



        /// <summary>
        /// Checks if WillShipExpedited property is set
        /// </summary>
        /// <returns>true if WillShipExpedited property is set</returns>
        public Boolean IsSetWillShipExpedited()
        {
            return  this.willShipExpeditedField != null;

        }


        /// <summary>
        /// Gets and sets the WillShipInternational property.
        /// </summary>
        [XmlElementAttribute(ElementName = "WillShipInternational")]
        public Boolean WillShipInternational
        {
            get { return this.willShipInternationalField.GetValueOrDefault() ; }
            set { this.willShipInternationalField= value; }
        }



        /// <summary>
        /// Sets the WillShipInternational property
        /// </summary>
        /// <param name="willShipInternational">WillShipInternational property</param>
        /// <returns>this instance</returns>
        public OfferAttributes WithWillShipInternational(Boolean willShipInternational)
        {
            this.willShipInternationalField = willShipInternational;
            return this;
        }



        /// <summary>
        /// Checks if WillShipInternational property is set
        /// </summary>
        /// <returns>true if WillShipInternational property is set</returns>
        public Boolean IsSetWillShipInternational()
        {
            return  this.willShipInternationalField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetCondition()) {
                xml.Append("<Condition>");
                xml.Append(EscapeXML(this.Condition));
                xml.Append("</Condition>");
            }
            if (IsSetSubCondition()) {
                xml.Append("<SubCondition>");
                xml.Append(EscapeXML(this.SubCondition));
                xml.Append("</SubCondition>");
            }
            if (IsSetConditionNote()) {
                xml.Append("<ConditionNote>");
                xml.Append(EscapeXML(this.ConditionNote));
                xml.Append("</ConditionNote>");
            }
            if (IsSetWillShipExpedited()) {
                xml.Append("<WillShipExpedited>");
                xml.Append(this.WillShipExpedited);
                xml.Append("</WillShipExpedited>");
            }
            if (IsSetWillShipInternational()) {
                xml.Append("<WillShipInternational>");
                xml.Append(this.WillShipInternational);
                xml.Append("</WillShipInternational>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}